package com.md.client.helper;

import com.fasterxml.jackson.core.type.TypeReference;
import com.md.api.OauthApi;
import com.md.base.BaseClient;
import com.md.model.system.BaseOpenController;
import com.md.model.system.CommonResult;
import com.md.request.ReplacementTokenRequest;
import com.md.response.ReplacementTokenResponse;

/**
 * @author 刘骄阳
 * 2024-10-11 15:05
 */
public class DefaultOauthApiController extends BaseOpenController implements OauthApi {

  public DefaultOauthApiController(final BaseClient baseClient,
                                   final String endpoint) {
    super(baseClient, endpoint, "oauth", PATH_PREFIX);
  }

  @Override
  public CommonResult<ReplacementTokenResponse> replacement(final ReplacementTokenRequest request) {
    return checkResponse(getBaseClient().post(buildPostUrl("/replacement"), request,
      new TypeReference<CommonResult<ReplacementTokenResponse>>() {
      }));
  }

}
